package com.treeroot.springbootwithwebsocket.controller;

import com.treeroot.springbootwithwebsocket.common.WebSocketServer;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.annotation.Resource;

public class WebSocketController {
    @Resource
    private WebSocketServer webSocketServer;

    @RequestMapping(value = "/sendTestMessage", method = RequestMethod.GET)
    public String sendTestMessage(String message) {
    //使用： const socketUrl = "ws://localhost:8080/websocket/sendTestMessage";
        webSocketServer.sendAllMessage(message);
        return "success";
    }
}
